package com.nio;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

/**
 * Created by Administrator on 2018/11/11/011.
 */
public class TestNioBuffer {
    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(10);
        IntBuffer buffer = IntBuffer.allocate(10);
        for (int i = 0; i < 5; i++) {
            buffer.put(i);
        }
        System.out.println("position:" + buffer.position());
        buffer.clear();
        System.out.println(buffer.position());
        buffer.put(99);
        System.out.println(buffer.position());
        System.out.println(buffer.get(0) + "==");
        System.out.println(buffer.position());
        System.out.println("=============");
        while (buffer.hasRemaining()) {
            int res = buffer.get();
            System.out.println(res);
        }
    }
}
